<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
define('NOSESSION',true);
require_once '../../core/core.php';
define('NO_ERROR_RETURN',true);
define('JSAPI',true);
//其他会员一键登录
if($_GET['i']){
	$_SESSION['uniacid']=$_GET['i'];
	unset($_GET['i']);
	$basic=plugin('jy_appsign')->plugin_setting('basic');
	if(!$basic['secret']){
		exit('基本设置-密钥未保存！');
	}
}else{
	exit('访问异常！');
}
if($_GET['appopenid'] && $_GET['timestamp'] && $_GET['sign']){
	$time=$_GET['timestamp'];
	if($time && ((TIMESTAMP+1800) >$time) && (TIMESTAMP-$time)<1800){
		$member=pdo_get('core_members',array('appopenid'=>trim($_GET['appopenid']),'uniacid'=>$_SESSION['uniacid']),array('id'));
		$sign=$_GET['sign'];
		$str=$_GET['appopenid'].$_GET['url'].$_GET['timestamp'].$basic['secret'];
		$check_sign=md5($str);
		if($check_sign == $sign){
			if($member['id']){
				model('core/member')->login($member['id']);
			}else{
				$member=array(
					'appopenid'=>trim($_GET['appopenid'])
				);
				$uid=model('core/member')->register($member);
				model('core/member')->login($uid);
			}
			if($_GET['url']){
				$_GET['url']=base64_decode($_GET['url']);
				$url=custom_url($_GET['url'],true);
				header('Location:'.$url);
			}else{
				exit('传参网址错误！');
			}
		}else{
			exit('签名错误,自动登录失败！');
		}
	}else{
		exit('免签登录签名已失效！');
	}
}else{
	exit('参与异常！');
}